'use strict';
const db = uniCloud.database()

exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	var dbName = 'ad-list'; //集合名称(表的名称)
	const res = await db.collection(dbName).get();
	console.log(res);
	var adConfig = {};
	for(var i in res.data){
		var tmp = res.data[i];
		console.log(tmp)
		var status = tmp['status']
		if(status == 1){
			adConfig[tmp['adname']] = tmp['ad_id']	
		}
	}
	console.log(adConfig);
	//返回数据给客户端
	return adConfig
};
